package com.jml;


import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;
import io.netty.util.AttributeKey;

/**
 * @author:jml
 * @date: 2019/9/23 17:58
 * @description：
 */
public class ClientHandler extends ChannelInboundHandlerAdapter {

	@Override
	public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
		System.out.println("客户端开始读取数据===============");
		System.out.println("客户端接收数据为"+msg.toString());
		
		//设置属性值
		ctx.channel().attr(AttributeKey.valueOf("ChannelKey")).set("zxzxccv");
		
		ctx.channel().close();
	}

	@Override
	public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception {
		super.userEventTriggered(ctx, evt);
	}

}
